import 'package:base_flutter/base_flutter.dart';
import 'package:ls_work/message/message_config.dart';
import 'package:ls_work/model/medicine_advice_model.dart';
import 'package:ls_work/viewmodel/medecine/medical_advice_manage_view_model.dart';

import '../../net/response/medicine_advice/medical_prescroption_list_data.dart';

class MedicalPrescriptionListViewModel extends BaseListViewModel<MedicalPrescroptionListData> {
  MedicalPrescriptionListViewModel(super.context);

  var model = MedicineAdviceModel();

  @override
  Future<List<MedicalPrescroptionListData>> requestListData() async {
    return await model.prescriptionList(
        page: page,
        rows: pageLength,
        prescriptionNoLike: MedicalAdviceManageViewModel.prescriptionCode,
        customerNameLike: MedicalAdviceManageViewModel.searchName,
        bedNoLike: MedicalAdviceManageViewModel.roomName,
        treatmentCardLike: MedicalAdviceManageViewModel.cardNo,
        doctorLike: MedicalAdviceManageViewModel.doctor,
        prescriptionDateLike: MedicalAdviceManageViewModel.prescriptionDate);
  }

  @override
  void onCreated() {
    super.onCreated();
    requestRefresh();
  }

  @override
  void receiveMessage(SendMessageEvent event) {
    super.receiveMessage(event);
    if (event.msgCode == MessageConfig.REFRESH_MEDICAL) {
      requestRefresh();
    }
  }
}
